package org.example.mallchat.dao;

import org.example.mallchat.domain.entity.UserRole;
import org.example.mallchat.mapper.UserRoleMapper;
import org.example.mallchat.service.iservice.IUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * <p>
 * 用户角色关系表 服务实现类
 * </p>
 *
 * @author 
 * @since 2024-12-25
 */
@Service
public class UserRoleDao extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {

    @Override
    public Set<Long> getRolesByUid(Long validUid) {
        List<UserRole> userRoleList = this.lambdaQuery().eq(UserRole::getUid, validUid).select(UserRole::getRoleId).list();
        return userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toSet());
    }
}
